package com.itheima.day06.sort_bubble;

import java.util.Arrays;

public class TestXuanze {
    public static void main(String[] args) {
        //1.创建一个数组
        int[] arr = {10, 5, 6, 8, 9, 2, 1, 3, 4, 7};
        System.out.print("排序前的数组："+ Arrays.toString( arr));
        System.out.println("");
        int [] arr1 = {1,23,45,55,12,32,67,32,567,432};
        System.out.print("排序前的数组2："+ Arrays.toString( arr1));
        System.out.println("");


        compare1(arr);
        System.out.println("");
        compare1(arr1);
    }
    public static void compare1(int[] arr) {


        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = i+1; j < arr.length; j++) {
                if (arr[i] > arr[j]) {
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}